<template>
  <block v-if="dictType">
    <el-checkbox-group v-model="value" @change="$emit('update:modelValue', $event)">
      <el-checkbox v-for="item in dataList" :key="item.dictValue" :label="item.dictValue" :value="item.dictValue" >{{ item.dictLabel }} </el-checkbox>
    </el-checkbox-group>
  </block>
  <bloc v-else>
    <el-checkbox-group v-model="value" @change="$emit('update:modelValue', $event)">
      <el-checkbox v-for="item in ObjectList" :key="item.id" :label="item.name" :value="item.id" >{{ item.name }} </el-checkbox>
    </el-checkbox-group>
  </bloc>

</template>
<script lang="ts">
import { getDictDataList } from "@/utils/utils";
import { computed, defineComponent } from "vue";
import { useAppStore } from "@/store";
export default defineComponent({
  name: "RenCheckboxGroup",
  props: {
    modelValue: [Number, String],
    dictType: String,
    objList: Array
  },
  setup(props) {
    const store = useAppStore();
    return {
      value: [],
      dataList: getDictDataList(store.state.dicts, props.dictType),
      ObjectList: props.objList || [] as any
    };
  }
});
</script>
